package Nisha.JDBC.JDBCdemo;

import static org.junit.Assert.*;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.junit.Test;

public class getConnectionTest {

	@Test
	public void test() throws SQLException {
		jdbcGetConnection con = new jdbcGetConnection();
		Connection connection =con.getMySQLConnection();
		Statement stmt = connection.createStatement();
		ResultSet rs = stmt
				.executeQuery("select  user_name,id, password from employee");
		
		while (rs.next()) {
			// always fetch the data using column names and avoid use of index
			// like rs.getInt(1).. preferred option is to do like
			// rs.getInt("id"). this is future.
			System.out.println("Employee Id  : " + rs.getInt("id")
					+ "  user_name  :" + rs.getString("user_name")
					+ "   password :" + rs.getString("password"));
		}
		rs.close();
		connection.close();
	}

}
